if [ -d /usr/local/ssl ]
then
    bin=/usr/local/ssl/bin/openssl
else
    bin=openssl
fi
version=$($bin version | cut -f2 -d" ")

msg="落红岂是无情物，化作春泥更护花。"
echo "plain: $msg"
echo

iv_64=0000000000000000
iv_128=00000000000000000000000000000000
key_64=C54E6F7DD4DACC1A
key_128=C54E6F7DD4DACC1AC5B0FA66565A4A60 
key_192=C54E6F7DD4DACC1AC5B0FA66565A4A6036902FDE85880CF4
key_256=C54E6F7DD4DACC1AC5B0FA66565A4A6036902FDE85880CF4C668AF6B987DB8D0

echo "*******************"
echo "* DES-CBC(passwd) *"
echo "*******************"
echo -n $msg | $bin des-cbc -nosalt -pass pass:Titanic | xxd -u -p - 
echo

echo "***********"
echo "* DES-CBC *"
echo "***********"
echo -n $msg | $bin des-cbc -nosalt -iv $iv_64 -K $key_64 | xxd -u -p - 
echo

echo "***********"
echo "* DES-ECB *"
echo "***********"
echo -n $msg | $bin des-ecb -nosalt -iv $iv_64 -K $key_64 | xxd -u -p - 
echo

echo "***************"
echo "* DES-EDE-CBC *"
echo "***************"
echo -n $msg | $bin des-ede-cbc -nosalt -iv $iv_64 -K $key_128 | xxd -u -p - 
echo

#if [ $(expr $version : '0\.9\.6') -eq 0 ]
#then
#    echo "***************"
#    echo "* DES-EDE-ECB *"
#    echo "***************"
#    echo -n $msg | $bin des-ede-ecb -nosalt -iv $iv_64 -K $key_128 | xxd -u -p - 
#    echo
#fi

echo "****************"
echo "* DES-EDE3-CBC *"
echo "****************"
echo -n $msg | $bin des-ede3-cbc -nosalt -iv $iv_64 -K $key_192 | xxd -u -p - 
echo

#if [ $(expr $version : '0\.9\.6') -eq 0 ]
#then
#    echo "****************"
#    echo "* DES-EDE3-ECB *"
#    echo "****************"
#    echo -n $msg | $bin des-ede3-ecb -nosalt -iv $iv_64 -K $key_192 | xxd -u -p - 
#    echo
#fi

if [ $(expr $version : '0\.9\.6') -eq 0 ]
then
    echo "***************"
    echo "* AES-128-CBC *"
    echo "***************"
    echo -n $msg | $bin aes-128-cbc -nosalt -iv $iv_128 -K $key_128 | xxd -u -p -
    echo

    echo "***************"
    echo "* AES-128-ECB *"
    echo "***************"
    echo -n $msg | $bin aes-128-ecb -nosalt -iv $iv_128 -K $key_128 | xxd -u -p -
    echo

    echo "***************"
    echo "* AES-192-CBC *"
    echo "***************"
    echo -n $msg | $bin aes-192-cbc -nosalt -iv $iv_128 -K $key_192 | xxd -u -p -
    echo

    echo "***************"
    echo "* AES-192-ECB *"
    echo "***************"
    echo -n $msg | $bin aes-192-ecb -nosalt -iv $iv_128 -K $key_192 | xxd -u -p -
    echo

    echo "***************"
    echo "* AES-256-CBC *"
    echo "***************"
    echo -n $msg | $bin aes-256-cbc -nosalt -iv $iv_128 -K $key_256 | xxd -u -p -
    echo

    echo "***************"
    echo "* AES-256-ECB *"
    echo "***************"
    echo -n $msg | $bin aes-256-ecb -nosalt -iv $iv_128 -K $key_256 | xxd -u -p -
    echo
fi
